//
//  InformationViewController.m
//  MoXiProject
//
//  Created by 周筱雯 on 2017/7/17.
//  Copyright © 2017年 周筱雯. All rights reserved.
//

#import "InformationViewController.h"
#import "NewsTableViewCell.h"
#import "NewsDetailsViewController.h"

#import "ZJScrollPageView.h"
#import "MoreNewsView.h"
@interface InformationViewController ()<UITableViewDelegate,UITableViewDataSource,ZJScrollPageViewDelegate>
@property(strong, nonatomic)NSArray<NSString *> *titles;
@property (nonatomic, strong) ZJScrollPageView *scrollPageView;
@property(strong, nonatomic)NSArray<UIViewController *> *childVcs;
@property(nonatomic,strong)UITableView* newsTable;
@end

@implementation InformationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initNav];
    [self initUI];
    
    // Do any additional setup after loading the view.
}

-(void)initNav{
    
//    [self.navigationItem setTitle:@"更多资讯"];
    [self.view setBackgroundColor:DEF_COLOR_F0F0F0];
    
}

-(void)initUI{
    
    ZJSegmentStyle *style = [[ZJSegmentStyle alloc] init];
    //显示滚动条
    style.showLine = YES;
    // 颜色渐变
    style.gradualChangeTitleColor = NO;
    style.scrollTitle=NO;
    style.scrollLineColor=DEF_COLOR_MAINCOLOR;
    style.selectedTitleColor=DEF_COLOR_MAINCOLOR;
    self.titles = @[@"高频彩",
                    @"竞技彩",
                    @"时时彩",
                    @"福彩"
                    ];
    // 初始化
    _scrollPageView = [[ZJScrollPageView alloc] initWithFrame:CGRectMake(0, 0, DEF_DEVICE_WIDTH, DEF_DEVICE_HEIGHT- 64.0) segmentStyle:style titles:self.titles parentViewController:self delegate:self];
 
    [self.view addSubview:_scrollPageView];
    
}

//#pragma mark - Table view data source
//- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
//{
//    
//    return 1;
//}
//
//- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
//{
//    
//    return 5;
//    
//}
//
//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
//    
//    return [self tableView:tableView cellForRowAtIndexPath:indexPath].frame.size.height;
//}
//
//- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    
//    static NSString *CellIdentifier = @"moreNewsCell";
//    NewsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
//    
//    if (cell == nil) {
//        
//        cell = [[NewsTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
//    }
//
//    return cell;
//}
//-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
//
//    [tableView deselectRowAtIndexPath:indexPath animated:YES];
//    NewsDetailsViewController* vc=[[NewsDetailsViewController alloc]init];
//    vc.hidesBottomBarWhenPushed=YES;
//    vc.controllerFromWhere=UIViewControllerFromOther;
//    [self.navigationController pushViewController:vc animated:YES];
//
//}


- (NSInteger)numberOfChildViewControllers {
    return self.titles.count;
}

- (UIViewController<ZJScrollPageViewChildVcDelegate> *)childViewController:(UIViewController<ZJScrollPageViewChildVcDelegate> *)reuseViewController forIndex:(NSInteger)index {
    MoreNewsView<ZJScrollPageViewChildVcDelegate> *childVc = (MoreNewsView *)reuseViewController;
    
    if (!childVc) {
        childVc = [[MoreNewsView alloc] init];
        childVc.index = index;
//        NSLog(@"%d",childVc.index);
        
    }
    
    return childVc;
}

- (BOOL)shouldAutomaticallyForwardAppearanceMethods {
    
    return NO;
}

@end
